package day06;

/**
 * @author Xiao
 * @date 2021/7/6
 */
public class ChangeNumber {
    /*
        需求：
            int a = 10;  int b = 20;
            交换a和b变量的值
     */
    public static void main(String[] args) {
        int a = 10;
        int b = 20;
        System.out.println("num:\ta:" + a + "\t" + "b:" + b);
        tempChange(a, b);
        OperateChange(a, b);
    }

    private static void tempChange(int a, int b) {
        int temp = a;
        a = b;
        b = temp;
        System.out.println("method1:\ta:" + a + "\t" + "b:" + b);
    }

    private static void OperateChange(int a, int b) {
        a = a ^ b;
        b = a ^ b;
        a = a ^ b;
        System.out.println("method2:\ta:" + a + "\t" + "b:" + b);
    }
}
